package cn.edu.controller;

import cn.edu.domain.All;
import cn.edu.domain.PageBean;
import cn.edu.domain.teacher;
import cn.edu.service.dep_ExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Davey chan
 */
@RestController
@RequestMapping("/dep_Examine")
public class dep_ExamineController  {
  @Autowired
    private dep_ExamineService examineService;

    /*审核通过*/
    @RequestMapping("/agree")
    public Result agree(Integer id) {
        examineService.agree(id);
        return new Result(Code.UPDATE_OK,"pass");
    }
    /*审核不通过*/
    @RequestMapping("/disagree")
    public Result disagree(Integer id) {
        //        调用Service的同意
        examineService.disagree(id);
        return new Result(Code.UPDATE_ERR,"nopass");
    }
    /*查询未审核通过的页面*/
    @GetMapping("/{currentPage}/{pageSize}")
    public Result selectByPage(@PathVariable Integer currentPage,
                               @PathVariable Integer pageSize
    ){
        PageBean<All> pageBean = examineService.selectByPage(currentPage, pageSize);
        return new Result(Code.GET_OK,pageBean);
    }
    /*查询已审核通过的页面*/
    @RequestMapping("/selectByPage2")
    public Result selectByPage2( Integer currentPage, Integer pageSize){
        PageBean<teacher> pageBean = examineService.selectByPage2(currentPage, pageSize);
        return new Result(Code.GET_OK,pageBean);
    }

    /* 取消审核*/
    @RequestMapping("/cancle")
    public Result cancle(Integer id) {
        examineService.cancle(id);
        return new Result(Code.UPDATE_ERR,"ok");
    }
}
